<!DOCTYPE html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>监听属性</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>

<div id="app">
    <div>{{fullName}}</div>
    <input type="text" v-model="firstName">
    <input type="text" v-model="lastName">
</div>


<script>
    var app = new Vue({
            el: '#app',
            data: {
                firstName: 'zhang',
                lastName:'san',
                fullName: 'zhang san'
            },
        watch:{
            firstName(val) {
                this.fullName = val + '' + this.lastName;
            },
            lastName(val) {
                this.fullName=this.firstName+''+val;
            }

        }

        }
    )

</script>
</html>
